# -*- coding: utf-8 -*-
import os
import dashscope
import certifi

# 设置阿里云的API密钥
os.environ["DASHSCOPE_API_KEY"] = "sk-07f4d6aa6f2e4acbac21f47ddc07c0e3"  # 替换为您的阿里云API密钥

# 初始化dashscope客户端
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")

# 指定CA证书路径
os.environ['REQUESTS_CA_BUNDLE'] = r'C:\Projekt\VW_10638\translator\PREH-Root-CA01.crt'

# 测试调用
def test_model():
    try:
        response = dashscope.Generation.call(
            model='qwen2.5-32b-instruct',
            prompt='你好，你能帮我写一首关于春天的诗吗？'
        )
        
        if response.status_code == 200:
            print("模型回复：", response.output.text)
        else:
            print("请求失败，错误信息：", response.code, response.message)
    except Exception as e:
        print("发生错误：", e)

if __name__ == "__main__":
    test_model()